/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package ticketManager.controller;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import javax.ejb.EJB;

import javax.enterprise.context.RequestScoped;
import javax.inject.Named;

import ticketManager.ejb.ProductDAO;
import ticketManager.model.Product;

/**
 *
 * @author Administrator
 */
@Named
@RequestScoped
public class ListProductsController {

    @EJB
    ProductDAO pDAO;

    private List<Product> products = new ArrayList<>();
    private List<String> products_title = new ArrayList<>();

    public List<String> getProductsTitle() {
        products = pDAO.getAllProduct();
        Iterator i = products.iterator();
        while(i.hasNext())
        {
            products_title.add(((Product)i.next()).getTitle());
        }
        return products_title;
    }
    
    public List<Product> getProducts()
    {
        products = pDAO.getAllProduct();
        return products;
    }

}
